<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
   
    </style>
</head>
<body>
<button id="btn">按钮</button>
<div id="news">
    <img src="img/a.jpg" alt="" id="img">
</div>
<script src="js/jquery-3.6.0.min.js"></script>
<script>
$(function(){
    $("#img").hide();
    var html="";
    $("button").click(function(){
        $.ajax({
            url:"index.php",
            dataType:"json",
            success:function(data){
                //console.log(data[0].news);
                $.each(data,function(index,value){
                    $("#news").append("<p>"+value.news+"</p>")
                })
                
            },
        })
        
    })
    $(document).ajaxStart(function(){
        $("#img").show();
    }).ajaxStop(function(){
        $("#img").hide();
    })
})
</script>
</body>
</html>